import axios from "/@/utils/http/axios";
import {MethodEnum} from "/@/utils/http/axios/enum/method-enum";
import {PageModel} from "/@/api/system/model/CommonModel";
import {RoleMenuQueryModel, RoleMenuVOModel, RoleModel, RoleQueryModel} from "/@/api/system/model/RoleModel";

/**
 * 分页查询角色列表
 * @param data
 * @param callBack
 */
export function listRolePage(data: RoleQueryModel, callBack?: Function): Promise<PageModel<RoleModel[]>> {
    return axios.httpRequest("/system/role/listRolePage", MethodEnum.GET, data, {callBack});
}

/**
 * 查询所有角色
 * @param callBack
 */
export function listRoleAll(callBack?: Function): Promise<RoleModel[]> {
    return axios.httpRequest("/system/role/listRoleAll", MethodEnum.GET, {}, {callBack});
}



/**
 * 新增角色
 * @param callBack
 */
export function insertRole(data: RoleModel, callBack?: Function): Promise<void> {
    return axios.httpRequest("/system/role/insertRole", MethodEnum.POST, data, {callBack});
}

/**
 * 修改角色
 * @param callBack
 */
export function updateRole(data: RoleModel, callBack?: Function): Promise<void> {
    return axios.httpRequest("/system/role/updateRole", MethodEnum.POST, data, {callBack});
}

/**
 * 根据角色id删除角色
 * @param data
 * @param callBack
 */
export function deleteRoleByRoleId(roleId: string, callBack?: Function): Promise<void> {
    return axios.httpRequest("/system/role/deleteRoleByRoleId", MethodEnum.GET, {roleId}, {callBack});
}

/**
 * 根据角色id查询角色
 * @param roleId
 * @param callBack
 */
export function selectRoleByRoleId(roleId: string, callBack?: Function): Promise<RoleModel> {
    return axios.httpRequest("/system/role/selectRoleByRoleId", MethodEnum.GET, {roleId}, {callBack});
}

/**
 * 根据角色id查询角色
 * @param roleId
 * @param callBack
 */
export function selectRoleMenuVOByRoleId(roleId: string, callBack?: Function): Promise<RoleMenuVOModel> {
    return axios.httpRequest("/system/role/selectRoleMenuVOByRoleId", MethodEnum.GET, {roleId}, {callBack});
}

/**
 * 保存角色与菜单关联
 * @param data
 * @param callBack
 */
export function saveRoleMenu(data: RoleMenuQueryModel, callBack?: Function): Promise<void> {
    return axios.httpRequest("/system/role/saveRoleMenu", MethodEnum.POST, data, {callBack});
}

